<?php
	class Model_guide extends CI_Model{
		protected $_table="tbl_guides";
		public function __construct(){
			parent::__construct();
			$this->load->database();
		}
		public function listall($off,$start){
			$this->db->order_by("guide_id","DESC");
			$this->db->limit($off,$start);
			return $this->db->get($this->_table)->result_array();
		}
		public function search_ajax($name){
			$this->db->like("guide_title",$name);
			$this->db->limit(4);
		    return $this->db->get($this->_table)->result_array();
		}
		public function count_all(){
			return $this->db->count_all($this->_table);
		}
		public function add_guide($data){
			$this->db->insert($this->_table,$data);
		}
		public function del_guide($id){
			$this->db->where("guide_id",$id);
			$this->db->delete($this->_table);
		}
        public function detail($id) {
            return $this->db
                ->where('guide_id', $id)
                ->get($this->_table)
                ->result_array();
        }

		public function get_guidedata($id){
			$this->db->where("guide_id",$id);
			$query = $this->db->get($this->_table);
			return $query->row_array();
		}
		public function update($data,$id){
			$this->db->where("guide_id",$id);
			$this->db->update($this->_table,$data);
		}
		public function listcago(){
			return $this->db->get($this->_cago)->result_array();
		}
	}